﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using LayoutPlanning.Model;

namespace LayoutPlanning.Converters
{
    public class TaskTypeToVisabilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var par = parameter as string;
            if (string.IsNullOrEmpty(par))
                return Visibility.Collapsed;

            if (value is GeneralTask.WorkTaskType)
            {
                var v = (GeneralTask.WorkTaskType) value;


                switch (par)
                {
                    case ("Work"):
                        if (v == GeneralTask.WorkTaskType.Work) return Visibility.Visible;
                        break;
                    case "Walk":
                        if (v == GeneralTask.WorkTaskType.Walk) return Visibility.Visible;
                        break;
                    case "Carry":
                        if (v == GeneralTask.WorkTaskType.Carry) return Visibility.Visible;
                        break;
                    case "General":
                        if (v == GeneralTask.WorkTaskType.General) return Visibility.Visible;
                        break;
                }
            }
            else if (value is ControlType)
            {
                var v = (ControlType)value;


                switch (par)
                {
                    case ("Custom"):
                        if (v == ControlType.Custom) return Visibility.Visible;
                        break;
                    case "Square":
                        if (v == ControlType.Square) return Visibility.Visible;
                        break;
                    case "Circle":
                        if (v == ControlType.Circle) return Visibility.Visible;
                        break;
                    
                }
            }
            return Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}